/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Grafica.java
 *
 * Created on 2/11/2009, 12:05:06 PM
 */
package simulacion.interfaz;

import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.util.Iterator;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import simulacion.Configuracion;
import simulacion.simulatedAnnealing.Ejercicio;

/**
 *
 * @author edilson
 */
public class Grafica extends javax.swing.JPanel {

    BufferedImage imagen = null;
    Ejercicio ejercicio;

    /** Creates new form Grafica */
    public Grafica(Ejercicio ejercicio) {
        this.ejercicio = ejercicio;
        initComponents();
        crearImagen();
    }

    private void crearImagen() {

        XYSeries serie = new XYSeries("Serie");
        Iterator<Double> iterator = ejercicio.getHistoricoSolucion().iterator();
        for (int i = 0; i < ejercicio.getHistoricoSolucion().size(); i++) {
            serie.add(i, iterator.next());
        }

        XYSeriesCollection coleccionSeries = new XYSeriesCollection();
        coleccionSeries.addSeries(serie);

        JFreeChart chart =
                ChartFactory.createXYLineChart("Comportamiento Simulated Annealing",
                "Ciclo", "Solucion", coleccionSeries, PlotOrientation.VERTICAL,
                false,
                false,
                true);

        ChartPanel panel = new ChartPanel(chart);
        panel.setMouseZoomable(true);
        this.add(panel);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
